home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 430 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 76623,2065@compuserve.com  (Bobby Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question about destructor...
  5. Date: 4 Jan 1996 14:42:02 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4cgovq$oqo@dub-news-svc-4.compuserve.com>
  8. References: <4cegke$p5@newsbf02.news.aol.com> <4ces35$3iq$1@mhafn.production.compuserve.com>
  9. Reply-To: 76623,2065@compuserve.com (Bobby Martin)
  10. NNTP-Posting-Host: ad42-148.compuserve.com
  11. X-Newsreader: IBM NewsReader/2 v1.03
  12.  
  13. In <4ces35$3iq$1@mhafn.production.compuserve.com>, Nil Bannerjee <100704.1417@CompuServe.COM> writes:
  14. >   If you call the destructor of A from B's destructor then this 
  15. >will take care of the inherited attributes.
  16. >
  17. >CB::~CB()
  18. >{
  19. >    //your stuff..
  20. >    ..
  21. >    ..
  22. >    ~CA();
  23. >}
  24. Um, that's a bad idea.  The destructor for the base class  (~CA) is called 
  25. automatically after the child's destructor (~CB) completes, and should take care
  26. of the inherited private data object deletion (if the parent class was written and
  27. is being used properly).  You shouldn't ever need to explicitely call the parent's
  28. destructor.
  29.